package io.renren.modules.heartself.controller;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.heartself.entity.ShTeacherEntity;
import io.renren.modules.heartself.service.ShTeacherService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 教师表
 *
 * @author jlk
 * @email sunlightcs@gmail.com
 * @date 2021-11-18 14:16:49
 */
@RestController
@Api("教师管理")
@RequestMapping("/heartSelf/shTeacher")
public class ShTeacherController {
    @Autowired
    private ShTeacherService shTeacherService;

    /**
     * 列表
     */
    @GetMapping("/queryTeacherList")
    public R list(@RequestParam Map<String, Object> params) {
        PageUtils page = shTeacherService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/teacherInfo/{teacherId}")
//    @RequiresPermissions("heartself:shteacher:info")
    public R info(@PathVariable("teacherId") Long teacherId) {
        ShTeacherEntity shTeacher = shTeacherService.getById(teacherId);

        return R.ok().put("shTeacher", shTeacher);
    }

    /**
     * 保存
     */
    @PostMapping("/saveTeacher")
//    @RequiresPermissions("heartself:shteacher:save")
    public R save(@RequestBody ShTeacherEntity shTeacher) {
        shTeacherService.save(shTeacher);

        return R.ok();
    }

    /**
     * 修改
     */
    @PostMapping("/updateTeacher")
//    @RequiresPermissions("heartself:shteacher:update")
    public R update(@RequestBody ShTeacherEntity shTeacher) {
        shTeacherService.updateById(shTeacher);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/deleteTeacher")
//    @RequiresPermissions("heartself:shteacher:delete")
    public R delete(@RequestBody Long[] teacherIds) {
        shTeacherService.removeByIds(Arrays.asList(teacherIds));

        return R.ok();
    }

}
